package com.bjut.vendormgrsys.web.rest;

import com.bjut.vendormgrsys.web.dto.Success;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;

@Validated
public interface SysFileApi {
    @Operation(summary = "文件下载", description = "文件下载", tags={ "SysFileApi" })
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "成功", content = @Content(schema = @Schema(implementation = Success.class))) })
    @RequestMapping(value = "/sysFile/download",
            method = RequestMethod.GET)
    ResponseEntity<InputStreamResource> download(@Parameter(in = ParameterIn.DEFAULT, description = "", required=true, schema=@Schema()) @Valid @RequestParam String url) throws IOException;


    @Operation(summary = "文件展示", description = "文件展示", tags={ "SysFileApi" })
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "成功", content = @Content(schema = @Schema(implementation = Success.class))) })
    @RequestMapping(value = "/sysFile/fileShow",
            method = RequestMethod.GET)
    void fileShow(HttpServletResponse response, @Valid @RequestParam String url) throws IOException;

}
